/*
 * @Author: zhangxiao
 * @Email: zhangxiao0125@163.com
 * @Date: 2020-06-02 16:11:53
 * @Last Modified by:   zhangxiao
 * @Last Modified time: 2020-06-02 16:11:53
 * @Description: 用户向导请求数据
 */


import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_code_framework/model_data/guide/guide.dart';
import 'package:flutter_code_framework/model_data/user/data.dart';
import 'package:flutter_code_framework/utils/global.dart';
/// 用户向导
class ReqUserGuide {
  final Dio _dio;

  ReqUserGuide(this._dio);

  Future<Response> guide({@required int subjectId,@required int periodId,@required int gradeId,@required String jobTitle,bool isEdit=true}) {
   var rs= _dio.post('/User/guide', queryParameters: {
       "subjectId": subjectId,
        "periodId":periodId,
        "gradeId":gradeId,
        "jobTitle":jobTitle,
        "isEdit":isEdit
    }); 
    rs.then((value) =>_setUserData(value.data));
    return rs;
  }
 _setUserData(dynamic data){
   if(data!=null){
      UserData u=G.user.data;
      var guide= GuideData.fromJson(data);
      u.periodId=guide.periodId;
      u.gradeId=guide.gradeId;
      u.jobTitle=guide.jobTitle;
      u.subjectId=guide.subjectId;
      G.user.setData(u);
   }
  }
}